using System;
using System.Collections.Generic;
using System.Text;
using CMS.Core.Domain;
using CMS.Core.DataInterfaces;
using CMS.Data;
using CMS.Presenters.Views.ListManager;

namespace CMS.Presenters.Presenters.ListManager
{
    public class ListCauHinhBCPresenter
    {
        private List<CauHinhBC> objList;
        private IListCauHinhBCView iObjView;
        private ICauHinhBCDao iObjDAO;
        
        /// <summary>
        /// Raised when the user wants to cancel editing a object.  The containing ASPX page should 
        /// listen for this event.
        /// </summary>
        public EventHandler CancelUpdateEvent;

        /// <summary>
        /// Raised after the object has been successfully committed to the database. 
        /// </summary>
        public EventHandler UpdateCompleteEvent;

        //Attaches this presenter to the view's events.
        public ListCauHinhBCPresenter(IListCauHinhBCView iObjView, ICauHinhBCDao iObjDAO)
        {
            if (iObjView == null) throw new ArgumentNullException("View may not be null");
            if (iObjDAO == null) throw new ArgumentNullException("LoaiDonDao may not be null");
            this.iObjView = iObjView;
            this.iObjDAO = iObjDAO;

            SubscribeViewToEvents();
        }

        public ListCauHinhBCPresenter()
        {
        }


        void SubscribeViewToEvents()
        {
            iObjView.Load += OnViewLoad;
        }

        void OnViewLoad(object sender, EventArgs e)
        {
             //LoadViewFromModel();
        }

        public void LoadViewFromModel(string maNSD)
        {
            this.objList = this.iObjDAO.GetAllOrderMoreFields(new string[] { "ThuTu"}, true);
            iObjView.CauHinhBCList = objList;
        }

        #region Button Members
        // For Cancel button
        public void CancelUpdate()
        {
            CancelUpdateEvent(this, null);
        }
       
        #endregion
    }
}
